/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package cs137_chatapp;

import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author GON
 */
public class ServerApp extends Frame implements Runnable, ActionListener{
    ServerSocket server;
    Socket s;
    BufferedReader br;
    BufferedWriter bw;

    ServerApp(int port){
        try {
            server = new ServerSocket(port);
            server.setSoTimeout(5000);
            /*s = server.accept();

            br = new BufferedReader(new InputStreamReader(s.getInputStream()));
            bw = new BufferedWriter(new OutputStreamWriter(s.getOutputStream()));
            */
        } catch (IOException ex) {
            Logger.getLogger(ServerApp.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public static void main(String args[]){
        new ServerApp(2313);
    }

    public void run() {
        while(true){
            try {
                /********Accepting the Server Connections***********/
                s = server.accept();
            } catch (IOException ex) {
                Logger.getLogger(ServerApp.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }

    public void actionPerformed(ActionEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    private ArrayList clients;
}